//2009/07/26 16:55:41
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class GoldenChain
{
public:
    int minCuts(vector <int> sections)
	{
		/*
		int score = 0;
		sort(sections.begin(), sections.end());
		for(int i=0; i<sections.size() - score; i++)
		{
			score += sections[i];
			score = min(score, sections.size() - i);
		}
		return score;
		*/
		int links = 0;
		int remain = sections.size();
		int index = 0;
		sort(sections.begin(), sections.end());
		while(links < remain)
		{
			links++;
			sections[index]--;
			if(sections[index] == 0)
			{
				index++;
				remain--;
			}
		}
		return links;
	}
};
